package net.dgg.rz.production.utils;

import com.alibaba.fastjson.JSONObject;
import net.dgg.rz.production.dao.ProductOrderDao;
import net.dgg.rz.production.entity.ProductOrder;
import net.dgg.rz.production.entity.dto.BusOrderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @className ParamsBuildUtils
 * @Author Quanlin Wan
 * @Description //TODO
 * @Date 2019/3/28 10:02
 **/
@Component
public class ParamsBuildUtils {
    @Autowired
    ProductOrderDao productOrderDao;

    public BusOrderDto buildBusOrderDto(ProductOrder productOrder,JSONObject jsonObject) {
        BusOrderDto busOrderDto = new BusOrderDto();
        busOrderDto.setOrderId(productOrder.getOrderId());
        busOrderDto.setBtIdentifying(productOrder.getBusinessTypeCode());
        busOrderDto.setBtName(productOrder.getBusinessTypeName());
//        busOrderDto.setProductId(productId);
//        //产品名称。
//        busOrderDto.setProductName(productJson.getString("name"));
//        busOrderDto.setFlowUserId(flowUserId);
//        //流程人员名称
//        busOrderDto.setFlowUserName(String.valueOf(flowUser.get("name")));
//        busOrderDto.setContractNo(productOrder.getContractNo());
//        busOrderDto.setChannelId(channelId);
//        //渠道名称。
//        busOrderDto.setChannelName(String.valueOf(channelMap.get("name")));
//        busOrderDto.setProductAmount(productOrder.getMoney());
//        busOrderDto.setSmallBusiness(typeCode);
//        //业务类型名称。
//        busOrderDto.setSmallBusinessName(String.valueOf(busTypeMap.get("name")));
//        busOrderDto.setProductGoodsId(goodsId);
//        busOrderDto.setChildBelong(productOrder.getProductOrgId());
//        busOrderDto.setChildBelongName(productOrder.getProductOrgName());
//        busOrderDto.setProductAmount(amount);
        return busOrderDto;
    }

    /**
     * @return
     * @Author Quanlin Wan
     * @Description //TODO 融资销售子订单编号生成
     * @Date 10:47 2019/3/28
     * @Param
     **/
    public  String buildOrderBusinessNo(String orderNo) {
        Integer scOrderNum = productOrderDao.selectOrderCount(orderNo);
        Integer newNum = scOrderNum + 1;
        String newOrderNo = orderNo + "-" +newNum;
        return newOrderNo;
    }
}
